package com.taotao.druid.sqlparser.tbrouter;

import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter;

/**
 * @author fanbeibei
 * @version 1.2.0
 * @date 2022/2/19 17:20
 */
public class AddTableNameSuffixVisitorAdapter extends MySqlASTVisitorAdapter {

    //默认是没有自定义变量的 可以自己加
    private String suffix;

    public AddTableNameSuffixVisitorAdapter(String suffix) {
        this.suffix = suffix;
    }

    @Override
    public boolean visit(SQLExprTableSource x) {
        String name = x.getExpr().toString();
        x.setExpr(name + "_" + suffix);
        return true;
    }
}
